package Test;

import com.sun.org.apache.xerces.internal.impl.xpath.regex.Match;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test_ {
    public static void main(String[] args) {

        //老韩思路：先把点去掉
        //String regStr = "\\.+"
        //再把重复的 . 去掉
        String content = "我...我要...学学学学...编程java!";
        //String regStr1 = "(.)\\1{2,}";//我.我要.学.编程java!
        String regStr = "\\.+";//我.我要.学.编程java!
        Pattern pattern = Pattern.compile(regStr);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            content = matcher.replaceAll("");
            System.out.println(content);
        }
        String regStr1 = "(.)\\1+";//我.我要.学.编程java!
        Pattern pattern1 = Pattern.compile(regStr1);
        Matcher matcher1 = pattern1.matcher(content);
        while (matcher1.find()) {
            content = matcher1.replaceAll("$1");
            System.out.println(content);
        }

    }
}
